home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / rbbs_pc / mapl0301.zip / ANSICHAT.BAS < prev    next >
BASIC Source File  |  1993-03-01  |  18KB  |  363 lines

  1. ' $title: 'ANSIChat Split Screen Chat for RBBS-PC v17.4'
  2. '          By Dan Drinnon 8:903/2 1:313/6
  3. '              The Cellar Door RBBS (505) 763-1795 9600 v32
  4. '             Scott McNay 1:395/11
  5. '              The Wizard's II RBBS   (817) 554-5331 9600 v32
  6. '
  7. '   Copyright (c) 1992,1993 by Daniel T. Drinnon   All Rights Reserved
  8. '
  9. '   DO NOT Distribute in Modified Form!
  10. '
  11. '   SEE ANSICHAT.DOC for LIMITATIONS OF USE
  12. '
  13. 'REVISIONS:
  14. '1.00  -  06-28-92 Initial Release
  15. '1.01  -  06-29-92 Fix for F2 Shell to DOS from ANSICHAT
  16. '1.02  -  07-04-92 Prevent F10 from Loading another ANSIChat
  17. '                  Keep ANSIChat from showing 'RBBS' if that is already
  18. '                  part of the BBS name.
  19. '                  added support for Sysop's PgUp/PgDn (RBBSSUB3.BAS)
  20. '                  combined local and remote input routines
  21. '1.03  -  07-09-92 Greater control over ANSI colors independent of RBBS colors
  22. '1.04  -  07-13-92 Added control to keep ANSICHAT from popping up when
  23. '                  the sysop does not have ANSI installed according to
  24. '                  CONFIG.
  25. '1.05  -  07-19-92 Modified RBBSSUB3 to get status of ANSIChat Capability
  26. '                  in DRSTx.DEF after return from a DOOR.
  27. '                  Removed redundant code in RBBS-PC.BAS.
  28. '                  Included ANSIFUN - a mod to make a Ring instead of a BEEP
  29. '                  for Sysop Page.
  30. '1.06  -  07-04-92 Gave the remote the option to terminate the chat by
  31. '                  pressing ESC.
  32. '1.07  -  08-10-92 Fixed BackSpace routine to properly locate the cursor.
  33. '1.08  -  08-13-92 Fixed the wordwrap/color mix problem and tweaked the
  34. '                  ANSI commands and a couple other things to speed up
  35. '                  the I/O.
  36. '1.09  -  08-18-92 Changed the bottom line of the remote screen to not go
  37. '                  past line 23.
  38. '                  Changed ZIP distribution file name to ACHATxxx.ZIP where xxx
  39. '                  denotes the version number.
  40. '1.10  -  08-26-92 Removed "STATIC" from SUB headers to force string space to
  41. '                  be released after use.
  42. '                  Added GetUserScreenSize sub to determine user's screen size
  43. '                  so that screen layout can be determined dynamically.  Makes
  44. '                  ANSIChat more compatible with non-standard (25x80) screens.
  45. '                  Changed exit method to require ESC key to be pressed twice.
  46. '                  This is compatible with ANSIED, and prevents accidents when
  47. '                  user hits a cursor key.
  48. '
  49. '1.11  -  09-09-92 Put the STATIC back in for QB3.0 compilers!  Took out the
  50. '                  GetUserScreenSize routines until a bug with certain modems
  51. '                  which returns 1,1 as the size is squashed.
  52. '
  53. '1.12  -  02-09-93 Fixed colors for the "Chat Over..." String.
  54. '                  Added a Current Time Clock in the Upper Right and an
  55. '                  Elapsed Time Clock in the Upper Left screen
  56. '                  Added support for CTRL-F to cycle through the ForeGround
  57. '                  text colors.  This is independent on the local and remote.
  58. '                  Background color cycling was tested out, but although it
  59. '                  worked, it just made for a sloppy looking screen and did
  60. '                  not seem worth the extra code space.
  61. '
  62. ' $INCLUDE: 'RBBS-VAR.MOD'
  63. '
  64. ' $SUBTITLE: 'ANSIChat - ANSI Split Screen Chat Routine'
  65. '
  66. ' $PAGE
  67. '
  68. '  SUBROUTINE NAME    -- ANSIChat
  69. '
  70. '  INPUT PARAMETERS   -- None
  71. '
  72. '  OUTPUT PARAMETERS  -- None
  73. '
  74. '  SUBROUTINE PURPOSE -- Allows Split Screen ANSI Chat for RBBS
  75. '
  76. '
  77. DIM ANSIRow(1), ANSICol(1), ACColor$(1), HoldInput$(1), StartRow(1)
  78. DIM MaxRow(1), WasX$(1), LastChar$(1), ForeGround(8), ForeRotate(1)   ' 1.12RT
  79. DIM ForeHiLite(1)                                                    ' 1.12
  80. '
  81. Common Shared ANSIRow(), ANSICol(), ACColor$(), HoldInput$(), StartRow()
  82. Common Shared MaxRow(), WasX$(), LastChar$()                         ' 1.10
  83. Common Shared LocalOut, RemoteOut, SideOut
  84. Common Shared MenuColor1$, MenuColor2$
  85. Common Shared StartTime!, ElapsedTime!, ForeGround(), ForeRotate()   ' 1.12
  86. Common Shared ForeHiLite()                                           ' 1.12
  87. '
  88. 1000 SUB ANSIChat STATIC
  89. '
  90.      StartTime! = TIMER                                              ' 1.12
  91.      FOR count = 0 TO 7                                              ' 1.12
  92.         ForeGround(count) = count + 30                               ' 1.12
  93.      NEXT                                                            ' 1.12
  94.      LocalOut = 0
  95.      RemoteOut = 1
  96.      SideOut = LocalOut
  97.      TimeChatStarted! = TIMER                                        ' 1.10
  98.      ANSIRow(LocalOut) = 2
  99.      ANSIRow(RemoteOut) = 14
  100.      ANSICol(LocalOut) = 1
  101.      ANSICol(RemoteOut) = 1
  102.      ACColor$(LocalOut) = "32;40m"                              ' 1.08
  103.      ACColor$(RemoteOut) = "33;40m"                             ' 1.08
  104.      ForeRotate(LocalOut) = 2                                        ' 1.12
  105.      ForeHiLite(LocalOut) = 1                                        ' 1.12
  106.      ForeRotate(RemoteOut) = 3                                       ' 1.12
  107.      ForeHiLite(RemoteOut) = 1                                       ' 1.12
  108.      ZWasCM = ZTrue
  109.      ZSubParm = 1
  110.      HoldColorReset$ = ZColorReset$
  111.      MenuColor1$ = "33;44m"                                     ' 1.08
  112.      MenuColor2$ = "36;44m"                                     ' 1.08
  113.      ZColorReset$ = MenuColor2$                                      ' 1.03
  114.      CALL ANSIMenu
  115.      CALL ANSILocate (ANSIRow(LocalOut),ANSICol(LocalOut))
  116.      CALL QuickTPut1 (ACColor$(LocalOut) + ZSysopGreeting$)
  117.      CALL SplitScreenChat
  118.      ZWasCM = 0
  119.      CALL CheckTime(TimeChatStarted!,Elapsed!, 2)
  120.      ZSecsPerSession! = ZSecsPerSession! + Elapsed!
  121.      IF NOT ZLocalUser THEN _
  122.         ZAutoLogoff! = TIMER + ZWaitBeforeDisconnect
  123.      CALL ClearANSIScreen
  124.      ZColorReset$ = HoldColorReset$
  125.      CALL QuickTPut1(ZEmphasizeOff$ + ZCrLF$ + _                     ' 1.12
  126.           "Chat over.  BBS resuming" + ZColorReset$)                 ' 1.12
  127.      END SUB
  128. '
  129. 4000 SUB ANSIMenu STATIC
  130. '
  131.      LineBar$ = STRING$(80,177)                                      ' 1.08
  132.      CALL ClearANSIScreen
  133.      CALL ANSILocate (1,1)
  134.      CALL QuickTPut (MenuColor2$ + LineBar$,0)                       ' 1.03
  135.      IF INSTR(ZRBBSName$,"BBS") <> 0 THEN _                          ' 1.02
  136.         ZOutTxt$ = "░*>>> " + ZRBBSName$ + " ANSI Chat <<<*░" _      ' 1.02
  137.      ELSE _                                                          ' 1.02
  138.         ZOutTxt$ = "░*>>> " + ZRBBSName$ + " RBBS ANSI Chat <<<*░"   ' 1.02
  139.      temppos = (40 - (LEN(ZOutTxt$)/2))
  140.      CALL ANSILocate (1,temppos)
  141.      CALL QuickTPut (MenuColor1$ + ZOutTxt$,0)                       ' 1.03
  142.      CALL ANSILocate (13,1)
  143.      CALL QuickTPut (MenuColor2$ + LineBar$,0)                       ' 1.03
  144.      CALL ANSILocate (13,3)
  145.      CALL QuickTPut (MenuColor2$ + "░" + ZSysopFirstName$ + _       ' 1.03
  146.           " " + ZSysopLastName$ + "░",0)                            ' 1.03
  147.      CALL ANSILocate (13,43)
  148.      CALL QuickTPut (MenuColor2$ + "░" + ZActiveUserName$ + "░",0) ' 1.03
  149.      CALL Line25
  150.      END SUB
  151. '
  152. 5000 SUB ClearANSIScreen STATIC
  153. '
  154.      CALL QuickTPut ("",0)                                       ' 1.03
  155.      ZSubParm = 2
  156.      CALL Line25
  157.      ZSubParm = 0
  158.      CALL ANSILocate (1,1)
  159.      END SUB
  160. '
  161. 6000 SUB ANSILocate (ANSIRow,ANSICol) STATIC
  162. '
  163.      CALL QuickTPut ("" + MID$(STR$(ANSIRow),2) + ";" + _
  164.           MID$(STR$(ANSICol),2) + "H",0)
  165.      END SUB
  166. '
  167. 8000 SUB SplitScreenChat STATIC
  168. '
  169. 8001 HoldInput$(LocalOut) = ""                                       ' 1.01
  170.      HoldInput$(RemoteOut) = ""
  171.      MaxLen = 78
  172.      StartRow(LocalOut) = 2
  173.      StartRow(RemoteOut) = 14
  174.      MaxRow(LocalOut) = 12
  175.      MaxRow(RemoteOut) = 23                                          ' 1.09
  176.      ANSICol(LocalOut) = 1
  177.      ANSICol(RemoteOut) = 1
  178.      ANSIRow(LocalOut) = StartRow(LocalOut) + 1
  179.      ANSIRow(RemoteOut) = StartRow(RemoteOut)
  180.      WasX$(LocalOut) = ""
  181.      WasX$(RemoteOut) = ""
  182.      ZWaitExpired = ZFalse
  183. '
  184. 8010 ZAutoLogoff! = TIMER + ZWaitBeforeDisconnect
  185.      CALL Carrier
  186.      IF ZSubParm < 0 THEN _
  187.         CALL QuickTPut1 (ZEmphasizeOff$) : _                         ' 1.12
  188.         EXIT SUB
  189. '
  190. 8020 CALL FindFKey
  191.      TimeNow! = TIMER                                                ' 1.12
  192.      IF ZWasCM = 0 THEN _                                            ' 1.01
  193.         CALL FlushCom (ZCommPortStack$) : _                          ' 1.01
  194.         ZKeyPressed$ = "" : _                                        ' 1.01
  195.         CALL ANSIMenu : _                                            ' 1.01
  196.         ZWasCM = ZTrue : _                                           ' 1.01
  197.         GOTO 8001                                                    ' 1.01
  198.      IF TimeNow! - PrevTI! > 1.0 THEN                                ' 1.12
  199.         ElapsedTime! = TIMER                                         ' 1.12
  200.         CALL CheckTime (StartTime!,ElapsedTime!,2)                   ' 1.12
  201.         ChatHour = ElapsedTime! / 3600                               ' 1.12
  202.         ChatMin = (ElapsedTime! - ChatHour * 3600!) / 60             ' 1.12
  203.         ChatSec = ElapsedTime! - (ChatHour * 3600! + ChatMin * 60!)  ' 1.12
  204.         IF ChatSec < 0 THEN                                          ' 1.12
  205.            ChatSec = ChatSec + 60                                    ' 1.12
  206.            ChatMin = ChatMin - 1                                     ' 1.12
  207.         END IF                                                       ' 1.12
  208.         IF ChatMin < 0 THEN                                          ' 1.12
  209.            ChatMin = ChatMin + 60                                    ' 1.12
  210.            ChatHour = ChatHour - 1                                   ' 1.12
  211.         END IF                                                       ' 1.12
  212.         Hours$ = STR$(ChatHour)                                      ' 1.12
  213.         Mins$ = STR$(ChatMin)                                        ' 1.12
  214.         Secs$ = STR$(ChatSec)                                        ' 1.12
  215.         CALL Trim (Hours$)                                           ' 1.12
  216.         CALL Trim (Mins$)                                            ' 1.12
  217.         CALL Trim (Secs$)                                            ' 1.12
  218.         IF ChatHour < 10 THEN Hours$ = "0" + Hours$                  ' 1.12
  219.         IF ChatMin < 10 THEN Mins$ = "0" + Mins$                     ' 1.12
  220.         IF ChatSec < 10 THEN Secs$ = "0" + Secs$                     ' 1.12
  221.         CALL ANSILocate (1,1)                                        ' 1.12
  222.         CALL QuickTPut (MenuColor1$ + Hours$ + ":" + _               ' 1.12
  223.                         Mins$ + ":" + Secs$,0)                       ' 1.12
  224.         DisplayTime$ = LEFT$(TIME$,8)                                ' 1.12
  225.         CALL ANSILocate (1,73)                                       ' 1.12
  226.         CALL QuickTPut (MenuColor1$ + DisplayTime$ + _               ' 1.12
  227.                         ZEmphasizeOff$,0)                            ' 1.12
  228.         CALL ANSILocate (ANSIRow(SideOut),ANSICol(SideOut))          ' 1.12
  229.         PrevTI! = TimeNow!                                           ' 1.12
  230.      END IF                                                          ' 1.12
  231.      SideOut = LocalOut
  232.      WasX$(LocalOut) = ZKeyPressed$
  233.      IF ZKeyPressed$ = ZEscape$ THEN _
  234.         CALL QuickTPut1 (ZColorReset$ + ZEmphasizeOff$) : _       'Pe022493
  235.         EXIT SUB
  236.      IF WasX$(LocalOut) <> "" THEN _
  237.         GOTO 8060
  238. '
  239. 8030 IF ZLocalUser THEN _
  240.         GOTO 8010
  241.      SideOut = RemoteOut
  242.      IF ZCommPortStack$ <> "" THEN _
  243.         WasX$(RemoteOut) = LEFT$(ZCommPortStack$,LEN(ZCommPortStack$)-1) : _
  244.         GOTO 9000
  245.      CALL EofComm (Char)
  246.      IF Char <> -1 THEN _
  247.         GOTO 8050 _
  248.      ELSE _
  249.         GOTO 8010
  250. '
  251. 8050 ZAutoLogoff! = TIMER + ZWaitBeforeDisconnect
  252.      CALL GetCom (WasX$(RemoteOut))
  253. '
  254. 8060 'Control keys
  255.      LastChar$(SideOut) = RIGHT$(LastChar$(SideOut),1) + _           ' 1.10
  256.                           WasX$(SideOut)                             ' 1.10
  257.      IF WasX$(SideOut) = CHR$(8) THEN _
  258.         GOTO 8500 _
  259.      ELSE IF WasX$(SideOut) = CHR$(9) THEN _
  260.         GOTO 8510 _
  261.      ELSE IF WasX$(SideOut) = CHR$(13) THEN _
  262.         GOTO 8520
  263.      IF WasX$(SideOut) = CHR$(6) THEN       'CTRL-F foreground       ' 1.12
  264.         ForeRotate(SideOut) = ForeRotate(SideOut) + 1                ' 1.12
  265.         IF ForeRotate(SideOut) > 7 AND ForeHiLite(SideOut) = 1 THEN  ' 1.12
  266.            ForeHiLite(SideOut) = 0                                   ' 1.12
  267.            ForeRotate(SideOut) = 0                                   ' 1.12
  268.         END IF                                                       ' 1.12
  269.         IF ForeRotate(SideOut) > 7 THEN                              ' 1.12
  270.            ForeHiLite(SideOut) = 1                                   ' 1.12
  271.            ForeRotate(SideOut) = 0                                   ' 1.12
  272.         END IF                                                       ' 1.12
  273.         hilite$ = STR$(ForeHiLite(SideOut))                          ' 1.12
  274.         CALL Trim (hilite$)                                          ' 1.12
  275.         colorstr$ = STR$(ForeGround(ForeRotate(SideOut)))            ' 1.12
  276.         CALL Trim (colorstr$)                                        ' 1.12
  277.         ACColor$(SideOut) = ZEscape$ + "[" + _                       ' 1.12
  278.                             hilite$ + ";" + _                        ' 1.12
  279.                             colorstr$ + "m"                          ' 1.12
  280.         GOTO 8010                                                    ' 1.12
  281.      END IF                                                          ' 1.12
  282.      GOTO 9000
  283. '
  284. 8500 'BackSpace
  285.      IF HoldInput$(SideOut) <> "" THEN _                             ' 1.07
  286.         HoldInput$(SideOut) = LEFT$(HoldInput$(SideOut), _           ' 1.07
  287.                               LEN(HoldInput$(SideOut))-1)            ' 1.07
  288.      IF ANSICol(SideOut) > 1 THEN _
  289.         ANSICol(SideOut) = ANSICol(SideOut) - 1 : _                  ' 1.07
  290.         GOTO 8501                                                    ' 1.07
  291.      IF ANSICol(SideOut) = 1 THEN _                                  ' 1.07
  292.         GOSUB 8502 : _                                               ' 1.07
  293.         ANSICol(SideOut) = MaxLen - 1 : _                            ' 1.07
  294.         ANSIRow(SideOut) = ANSIRow(SideOut) - 1                      ' 1.03
  295.      IF ANSIRow(SideOut) < StartRow(SideOut) THEN _                  ' 1.07
  296.         ANSIRow(SideOut) = MaxRow(SideOut)                           ' 1.07
  297. 8501 GOSUB 8502                                                      ' 1.07
  298.      GOTO 8010
  299. 8502 CALL ANSILocate (ANSIRow(SideOut),ANSICol(SideOut))             ' 1.07
  300.      tempstr$ = ACColor$(SideOut) + " "                              ' 1.12
  301.      IF NOT ZLocalUser THEN _                                        ' 1.07
  302.         CALL PutCom (tempstr$)                                       ' 1.12
  303.      CALL LPrnt (tempstr$,0)                                         ' 1.12
  304.      CALL ANSILocate (ANSIRow(SideOut),ANSICol(SideOut))             ' 1.07
  305.      RETURN                                                          ' 1.07
  306. '
  307. 8510 'TAB
  308.      HoldInput$(SideOut) = ""
  309.      IF ANSICol(SideOut) + 5 > MaxLen THEN _
  310.         CALL AddRow (StartRow(SideOut),MaxRow(SideOut)) _
  311.      ELSE _
  312.         ANSICol(SideOut) = ANSICol(SideOut) + 5 : _
  313.         CALL ANSILocate (ANSIRow(SideOut),ANSICol(SideOut))
  314.      GOTO 8010
  315. '
  316. 8520 'CR
  317.      HoldInput$(SideOut) = ""
  318.      CALL AddRow (StartRow(SideOut),MaxRow(SideOut))
  319.      GOTO 8010
  320. '
  321. 9000 'Character Placement
  322.      IF LastChar$(SideOut) = ZEscape$ + ZEscape$ THEN _              ' 1.10
  323.            CALL QuickTPut1 (ZColorReset$ + ZEmphasizeOff$) : _   ' Pe022493
  324.            EXIT SUB
  325.      HoldInput$(SideOut) = HoldInput$(SideOut) + WasX$(SideOut)
  326.      IF WasX$(SideOut) = " " THEN _
  327.         HoldInput$(SideOut) = ""
  328.      IF ANSICol(SideOut) = MaxLen AND WasX$(SideOut) <> " " THEN _
  329.         CALL ANSILocate (ANSIRow(SideOut),ANSICol(SideOut) - _
  330.                          LEN(HoldInput$(SideOut))) : _
  331.         CALL QuickTput(ACColor$(SideOut) + "", 0) : _             ' 1.08
  332.         CALL AddRow (StartRow(SideOut),MaxRow(SideOut)) : _
  333.         CALL QuickTPut (HoldInput$(SideOut),0) : _
  334.         ANSICol(SideOut) = ANSICol(SideOut) + LEN(HoldInput$(SideOut)) - 1 : _
  335.         WasX$(SideOut) = "" : _
  336.         HoldInput$(SideOut) = ""
  337.      CALL ANSILocate (ANSIRow(SideOut),ANSICol(SideOut))
  338.      IF NOT ZLocalUser THEN _
  339.         CALL PutCom (ACColor$(SideOut) + WasX$(SideOut))
  340.      CALL LPrnt (ACColor$(SideOut) + WasX$(SideOut),0)
  341.      ANSICol(SideOut) = ANSICol(SideOut) + 1
  342.      IF ANSICol(SideOut) > MaxLen THEN _
  343.         CALL AddRow (StartRow(SideOut),MaxRow(SideOut))
  344.      WasX$(SideOut) = ""
  345.      GOTO 8010
  346.      END SUB
  347. '
  348. 10000 SUB AddRow (StartRow,MaxRow) STATIC
  349. '
  350.       ANSICol(SideOut) = 1
  351.       ANSIRow(SideOut) = ANSIRow(SideOut) + 1
  352.       IF ANSIRow(SideOut) > MaxRow THEN _
  353.          ANSIRow(SideOut) = StartRow
  354.       IF ANSIRow(SideOut) < MaxRow THEN _
  355.          CALL ANSILocate (ANSIRow(SideOut) + 1,ANSICol(SideOut)) : _
  356.          CALL QuickTput(ACColor$(SideOut) + "", 0)                ' 1.12
  357.       IF ANSIRow(SideOut) = MaxRow THEN _
  358.          CALL ANSILocate (StartRow,ANSICol(SideOut)) : _
  359.          CALL QuickTput(ACColor$(SideOut) + "", 0)                ' 1.12
  360.       CALL ANSILocate (ANSIRow(SideOut),ANSICol(SideOut))
  361.       END SUB
  362. '
  363.